#!/bin/bash
cd ~/app-root/data/temp/Nexus4
#cmUrl=$(curl -s "https://download.cyanogenmod.org/?device=mako" |grep get/jenkins |awk -F '\"' '{print $2}' |head -1)
#if ! grep -q "$cmUrl" cmUrl; then
#    echo $cmUrl > cmUrl
#    ~/app-root/data/github-sh/Nexus4/openload_uploader.sh remote "https://download.cyanogenmod.org$cmUrl" "Nexus4"
#fi
#CM13
CM13Fid=$(curl -s "https://www.androidfilehost.com/?a=show&w=files&flid=135376" |grep 'h4.*cm-13\.[a-zA-Z0-9\.\-]\{1,\}'|tail -1|grep -o 'fid=[0-9]\{1,\}')
if ! grep -q $CM13Fid CM13Fid; then
    echo $CM13Fid > CM13Fid
    cmUrl=$(curl -s "https://www.androidfilehost.com/libs/otf/mirrors.otf.php" --data "submit=submit&action=getdownloadmirrors&${CM13Fid}"|grep -o 'http[a-zA-Z0-9\/\\\.:\-]\{1,\}\.zip'|sed -e '2,$d' -e 's#\\\/#\/#g')
    ~/app-root/data/github-sh/Nexus4/openload_uploader.sh remote "$cmUrl" "OnePlus3T"
fi
#unofficial LineageOS For 3T
#CMTestBuild=$(curl -s http://vps355909.ovh.net/nightly/ |grep -o "[0-9]\{8\}"|tail -1)
#if ! grep -q "$CMTestBuild" CMTestBuild; then
#    echo $CMTestBuild > CMTestBuild
#    cmUrl=$(curl -s "http://vps355909.ovh.net/nightly/$CMTestBuild/" |grep -o "lineage[a-zA-Z0-9\.\-]\{1,\}\.zip" |head -1)
#    ~/app-root/data/github-sh/Nexus4/openload_uploader.sh remote "http://vps355909.ovh.net/nightly/$CMTestBuild/$cmUrl" "OnePlus3T"
#fi 
